import cookie from './cookie'
export const mixin = {
    data(){
        return{
            msgText: '',
            msgFlag: false,
            activeColor: ''
        }
    },
    methods:{
        msgTips(text = '', flag = false, color = '#dd6161'){
            this.msgText = text
            this.msgFlag = flag
            this.activeColor = color
            if(flag){
                setTimeout(() => {
                    this.msgTips()
                }, 1000)
            }
            // 例子：this.msgTips('修改成功!', true, '#67c23a');
            // 例子：this.msgTips('保存失败,不能含有空格', true);
        },
        handleGetTime(item){
            let st = {}, et = {}

            if(item != undefined){
                st.year = et.year = item.getFullYear()
                st.month = et.month = item.getMonth() + 1
                st.day = et.day = item.getDate()
            }else{
                st.year = this.time[0].getFullYear()
                st.month = this.time[0].getMonth() + 1
                st.day = this.time[0].getDate()
                et.year = this.time[1].getFullYear()
                et.month = this.time[1].getMonth() + 1
                et.day = this.time[1].getDate()
            }

            return {
                st: `${st.year}-${`00${st.month}`.substr(-2)}-${`00${st.day}`.substr(-2)}`,
                et: `${et.year}-${`00${et.month}`.substr(-2)}-${`00${et.day}`.substr(-2)}`
            }
        }
    }
}

// export const mixinCid = {
//   computed:{
//     cid(){
//       return this.$store.state.cid
//     }
//   },
//   watch:{
//     cid(){
//       this.initData()
//     }
//   },
// };

export const mixinControl = {
  computed:{
    getControl(){
      return cookie.get('hw_quality_control') === '1';
    }
  }
}